@(request: play.api.mvc.Request[play.api.mvc.AnyContent])
@import controllers.Ext 
@import play.api.i18n._
@scripts = {
	<script src="@routes.Assets.at("javascripts/ckeditor/ckeditor.js")" type="text/javascript"></script>
} 
@stylesheets = {
	
} 
@title = {
	@Messages("about_title")
}

@main(title, scripts, stylesheets) {
	//TODO: @Messages("about_title")
	@tags.PageContent(clientId =  "about", TagName = "div", ID = "test", CssClass = "editable")

	
	<div id="submitContent">Wyślij</div>
	<script>

		// Uncomment the following code to test the "Timeout Loading Method".
		// CKEDITOR.loadFullCoreTimeout = 5;

		
		
		window.onload = function() {
			// Listen to the double click event.
			if ( window.addEventListener )
				document.body.addEventListener( 'dblclick', onDoubleClick, false );
			else if ( window.attachEvent )
				document.body.attachEvent( 'ondblclick', onDoubleClick );

		};

		function onDoubleClick( ev ) {
			// Get the element which fired the event. This is not necessarily the
			// element to which the event has been attached.
			var element = ev.target || ev.srcElement;

			// Find out the div that holds this element.
			var name;

			do {
				element = element.parentNode;
			}
			while ( element && ( name = element.nodeName.toLowerCase() ) &&
				( name != 'div' || element.className.indexOf( 'editable' ) == -1 ) && name != 'body' );

			if ( name == 'div' && element.className.indexOf( 'editable' ) != -1 )
				replaceDiv( element );
		}

		var editor;

		function replaceDiv( div ) {
			if (window.location.href.indexOf("editable=true") != -1){
				if ( editor )
					editor.destroy();
                CKEDITOR.config.entities = false;
                CKEDITOR.config.entities_latin = false;
                CKEDITOR.config.fillEmptyBlocks = false;
				editor = CKEDITOR.replace( div );
			}
			
		}

	</script>
	<script type="text/javascript">
	$(document).ready(function(){
		$('#submitContent').click(function(){
			$.post('/submitpc/?id=about&content=' + editor.getData(), function(data) {
				alert(data);
		});
		
		});
	});
	</script>
}
